<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <script src="../script/api.js"></script>
    <style>

    </style>
</head>

<body>
    <header id='header' class="aui-bar aui-bar-nav" style="background-color: #03a9f4">
        <a class="aui-pull-left aui-btn" onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="middle">
            批次发货
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:0px;">
        <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form>
                        <input type="search" placeholder="请输入计划单号" id="name">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4" onclick="doSearch()">搜索</div>
            <!-- <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4" onclick="test()">ceshi1</div> -->
        </div>
        <ul class="ui-selectee" id="tbodyHtml">

            <!-- <li class='sortable ui-selectee ui-sortable'>
                <ul class='aui-list aui-media-list ui-selectee'>
                    <li class='aui-list-item ui-selectee'>
                        <div class='aui-media-list-item-inner ui-selectee'>
                            <div class='aui-list-item-inner ui-selectee'>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>发货单号</div>
                                    <div class='aui-list-item-inner ui-selectee'>SP-20210810-0006</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>发货计划号</div>
                                    <div class='aui-list-item-inner ui-selectee'>DP-20210810-0011</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>发货日期</div>
                                    <div class='aui-list-item-inner ui-selectee'>2021-08-10</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>供应商编码</div>
                                    <div class='aui-list-item-inner ui-selectee'>121</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>供应商名称</div>
                                    <div class='aui-list-item-inner ui-selectee'>121</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>物料编码</div>
                                    <div class='aui-list-item-inner ui-selectee'>WOOgsgah0880</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>物料名称</div>
                                    <div class='aui-list-item-inner ui-selectee'>螺丝B2</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title'>计划发货数量</div>
                                    <div class='aui-list-item-inner ui-selectee'>17</div>
                                </div>
                                <div class='aui-list-item-text ui-selectee' style='height: 30px;'>
                                    <div class='aui-list-item-label ui-selectee list-tr-title' style="width: 45%;">实际发货数量</div>
                                    <div class='aui-list-item-inner ui-selectee' style="margin-left: 0.1rem;">0</div>
                                    <div class='aui-list-item-right aui-btn ui-selectee' onclick='goPageDetail("2201b3bab776442ab90e4ef3ee89f88f","SP-20210810-0006","undefined");'>发货</div>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </li> -->

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script>
    apiready = function() {
        // console.log("9999999999999");
        $("#name").focus();
        idSelector = "name";
        //今天的时间
        var dayS = new Date();
        dayS.setTime(dayS.getTime());
        var mm = (dayS.getMonth() + 1) >= 10 ? (dayS.getMonth() + 1) : "0" + (dayS.getMonth() + 1);
        var dd = dayS.getDate() >= 10 ? dayS.getDate() : "0" + dayS.getDate();
        var start =
            dayS.getFullYear() + "-" + mm + "-" + dd;
        doSearch(start);
    }


    //查询
    function doSearch(dateS) {
        //光标所在id
        var idSelector = "";
        var name = ""; //发货单号
        //发货单号
        var name = $("#name").val();
        if (name != null && name != undefined && name != "") {
            name = name.trim();
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/wminvoiceinfoList";
        var data = {
            values: {
                code: name,
                // statusList: "0,1",//筛选创建状态和发货中状态发货单
                invoicedate: dateS, //默认筛选当天
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    var html = "";
                    for (var i = 0; i < list.length; i++) {
                        html += "<li class='sortable ui-selectee ui-sortable'>";
                        html += "<ul class='aui-list aui-media-list ui-selectee'>";
                        html += "<li class='aui-list-item  ui-selectee'>";
                        html += "<div class='aui-media-list-item-inner ui-selectee'>";
                        html += "<div class='aui-list-item-inner ui-selectee'>";
                        html += "<div class='aui-list-item-text ui-selectee'  style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>发货计划号</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].invoiceplancode + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>发货单号</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].code + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>发货日期</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].invoicedate + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'  style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>客户编码</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].customerSendCode + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>客户名称</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].customerSendName + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'  style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>物料编码</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].mrlCode + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>物料名称</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].mrlName + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'  style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>计划发货数量</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].planQty + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'  style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>已绑定数量</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].bdQty + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width: 45%;'>实际发货数量</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-left: 0.1rem;'>" + list[i].actualQty + "</div>";
                        html += "<div class='aui-list-item-right aui-btn ui-selectee' " +
                            "onclick='goPageDetail(\"" + list[i].sysid + "\",\"" + list[i].code + "\",\"" + list[i].invoicedate + "\",\"" + list[i].customerSendCode + "\",\"" + list[i].customerSendName + "\",\"" + list[i].mrlCode + "\",\"" +
                            list[i].mrlName + "\",\"" + list[i].planQty + "\",\"" + list[i].actualQty + "\");'>发货</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</li>";
                        html += "</ul>";
                        html += "</li>";
                    }
                    // console.log("htmlhtml",html);
                    $api.html($api.byId("tbodyHtml"), html);
                    //失败
                } else if (myobj.code == "1") {
                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    function test() {
        $api.html($api.byId("tbodyHtml"), "");
    }
    //跳转详情页面
    function goPageDetail(sysid, code, invoicedate, customerSoldCode, customerSoldName, mrlCode, mrlName, planQty, actualQty) {
        //打开页面
        api.openWin({
            name: 'wmRiskLibraryShipmentDetail',
            url: 'wmRiskLibraryShipmentDetail' + '.html',
            pageParam: {
                sysid: sysid,
                code: code,
                invoicedate: invoicedate,
                customerSoldCode: customerSoldCode,
                customerSoldName: customerSoldName,
                mrlCode: mrlCode,
                mrlName: mrlName,
                planQty: planQty,
                actualQty: actualQty
            },
        });
    }

    //刷新数据
    function refreshData() {
        var dayS = new Date();
        dayS.setTime(dayS.getTime());
        var mm = (dayS.getMonth() + 1) >= 10 ? (dayS.getMonth() + 1) : "0" + (dayS.getMonth() + 1);
        var dd = dayS.getDate() >= 10 ? dayS.getDate() : "0" + dayS.getDate();
        var start =
            dayS.getFullYear() + "-" + mm + "-" + dd;
        doSearch(start);
    }
</script>

</html>
